#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include "elapsed.cpp"
using namespace std;

int main(int argc, char **argv)
{
   int N;
   int P;
   int c;
   
	while ((c = getopt(argc, argv, "n:p:")) != -1) {
		switch(c) {
			case 'n':
				N = atoi(optarg);
				break;
			case 'p':
			    P = atoi(optarg);
				break;
			case '?':
				cerr << "Please enter a number:" << endl;
				return 1;
			default:
				abort();
			}
    }

    struct timespec start, end, res;

    vector<int> myvector;
    vector<int>::iterator itVec;

    list<int> mylist;
    list<int>::iterator itList;
	
	map<int, int> mymap;

    gettime(start);
	for (int i = 0; i < N; i++) {
		myvector.push_back(i);
		}
    gettime(end);
    res =  diff(start, end);
    cout << "vector inserting costs " << res.tv_sec + res.tv_nsec / 10.0e9 
        << " seconds." << endl;
		
	gettime(start);
	myvector.clear();
	gettime(end);
	res = diff(start, end);
    cout << "vector removing costs " << res.tv_sec + res.tv_nsec / 10.0e9 
        << " seconds." << endl;

    gettime(start);
	for (int i = 0; i <= N; i++) {
	    mylist.push_back(i);}
    gettime(end);
    res = diff(start, end);
    cout << "list inserting costs " << res.tv_sec + res.tv_nsec / 10.0e9 
        << " seconds." << endl;

	gettime(start);
	mylist.clear();
	gettime(end);
	res = diff(start, end);
    cout << "list removing costs " << res.tv_sec + res.tv_nsec / 10.0e9 
        << " seconds." << endl;
		
	gettime(start);
	for (int i = 0; i <= N; i ++) {
	    mymap[i] = i;
	}
	gettime(end);
	res = diff(start, end);
    cout << "map inserting costs " << res.tv_sec + res.tv_nsec / 10.0e9 
        << " seconds." << endl;
		
	gettime(start);
	mymap.find(P);
	res = diff(start, end);
    cout << "map finding costs " << res.tv_sec + res.tv_nsec / 10.0e9 
        << " seconds." << endl;
		
	gettime(start);
	mymap.clear();
	gettime(end);
	res = diff(start, end);
    cout << "map removing costs " << res.tv_sec + res.tv_nsec / 10.0e9 
        << " seconds." << endl;
    }
		
    
	
	
	